<template>
  <s-modal title="详情" :visible="visible" width="800px" :footer="null" @cancel="visible = false">
    <div style="height: 400px">
      <s-scroll>
        <s-form :value="formValue">
          <s-form-item label="流程名称" name="flowName">
            <s-input v-model="formValue.flowName" placeholder="流程名称" disabled />
          </s-form-item>
          <s-form-item label="流程类型" disabled name="flowType">
            <s-select
              v-model="formValue.flowType"
              code="FLOW_TYPE"
              disabled
              allow-clear
              placeholder="流程类型"
            />
          </s-form-item>
          <s-form-item
            label="流程存储策略"
            name="flowStoragePolicy"
            size="custom"
            tip="用来存储当前流程的各种数据。当选择业务表冗余时，业务表内必须包括所有的冗余字段。当选择新建表时，无需创建表，表会自动创建。"
            :options="{ labelWidth: 8, wrapperWidth: 16, offsetWidth: 0, total: 12 }"
          >
            <s-select
              v-model="formValue.flowStoragePolicy"
              code="FLOW_RUN_STORAGE_POLICY"
              allow-clear
              disabled
              placeholder="流程存储策略"
            />
          </s-form-item>
          <s-form-item label="流程存储表" name="flowStorageTable">
            <s-input
              v-model="formValue.flowStorageTable"
              allow-clear
              disabled
              placeholder="流程存储表"
            />
          </s-form-item>

          <s-form-item
            label="任务存储策略"
            name="taskStoragePolicy"
            size="custom"
            tip="用来存储当前流程执行中的任务信息。"
            :options="{ labelWidth: 8, wrapperWidth: 16, offsetWidth: 0, total: 12 }"
          >
            <s-select
              v-model="formValue.taskStoragePolicy"
              code="TASK_RUN_STORAGE_POLICY"
              allow-clear
              disabled
              placeholder="任务存储策略"
            />
          </s-form-item>
          <s-form-item
            v-if="formValue.taskStoragePolicy == '2'"
            label="任务存储表"
            name="taskStorageTable"
          >
            <s-input
              v-model="formValue.taskStorageTable"
              allow-clear
              disabled
              placeholder="任务存储表"
            />
          </s-form-item>
          <s-form-item
            label="历史存储策略"
            name="historyStoragePolicy"
            size="custom"
            tip="用来存储当前流程的历史数据。当选择通用表存储时，历史数据会存入skrivet_work_flow_history中。当选择新建表时，无需创建表，表会自动创建。"
            :options="{ labelWidth: 8, wrapperWidth: 16, offsetWidth: 0, total: 12 }"
          >
            <s-select
              v-model="formValue.historyStoragePolicy"
              code="FLOW_HISTORY_STORAGE_POLICY"
              allow-clear
              disabled
              placeholder="历史存储策略"
            />
          </s-form-item>
          <s-form-item
            v-if="formValue.historyStoragePolicy == '2'"
            label="历史存储表"
            disabled
            name="historyStorageTable"
          >
            <s-input
              v-model="formValue.historyStorageTable"
              allow-clear
              disabled
              placeholder="历史存储表"
            />
          </s-form-item>
          <s-form-item label="流程描述" name="flowDescribe" size="big">
            <s-input v-model="formValue.flowDescribe" type="textarea" disabled />
          </s-form-item>
          <s-form-item label="创建人">
            <s-input v-model="formValue.createByAccount" disabled />
          </s-form-item>
          <s-form-item label="创建时间">
            <s-input v-model="formValue.createDate" disabled />
          </s-form-item>
          <s-form-item label="修改人">
            <s-input v-model="formValue.updateByAccount" disabled />
          </s-form-item>
          <s-form-item label="修改时间">
            <s-input v-model="formValue.updateDate" disabled />
          </s-form-item>
        </s-form>
      </s-scroll>
    </div>
  </s-modal>
</template>

<script>
export default {
  name: 'Detail',
  data() {
    return {
      formValue: {},
      visible: false
    }
  },
  methods: {
    open(id) {
      this.$loading(true)
      this.$api
        .GET('/workflow/define/selectOneById', { id: id })
        .then((res) => {
          if (!res.data) {
            this.$loading(false)
            this.visible = false
            this.$message.warn('数据不存在')
          } else {
            this.formValue = res.data
            this.$loading(false)
            this.visible = true
          }
        })
        .catch(() => {
          this.$loading(false)
        })
    }
  }
}
</script>

<style lang="less" scoped></style>
